# 人生重开模拟器
# 引进的模块
import random
import sys
import time

print("+-----------------------------------------------+")
print("|        花有重开日，人无在少年                     |")
print("|                                               |")
print("|        欢迎来到人生重开模拟器                     |")
print("+-----------------------------------------------+")

# 设置初始属性
# 颜值，体质，智力，家境 总和不超过20，每个1~10
while True:
    face = int(input("请输入颜值(1~10):"))
    strong = int(input("请输入体质(1~10):"))
    iq = int(input("请输入智力(1~10):"))
    home = int(input("请输入家境(1~10):"))

    if face < 1 or face > 10:
        print("颜值设置错误")
        continue
    if strong < 1 or strong > 10:
        print("体质设置错误")
        continue
    if iq < 1 or iq > 10:
        print("智力设置错误")
        continue
    if home < 1 or home > 10:
        print("家境设置错误")
        continue

    if face + strong + iq + home > 20:
        print("总和设置错误")
        continue

    print("属性设置成功")
    print(f"颜值:{face},体质:{strong},智力:{iq},家境:{home}")
    break

# 生成性别
# 使用random.randint(beg,end),可以生成[beg,end]随机整数
point = random.randint(1, 6)
if point % 2 == 1:
    gender = "boy"
    print("你是个男孩")
else:
    gender = "girl"
    print("你是个女孩")

# 设置角色的出生点
point = random.randint(1, 3)
if home == 10:
    print("你出生在大城市，父母是公务员")
    home += 1
    iq += 1
    face += 1
elif 7 <= home <= 9:
    if point == 1:
        print("你出生在大城市，父母是公务员")
        face += 2
    elif point == 2:
        print("你出生在大城市，父母是企业高管")
        home += 2
    else:
        print("你出生在大城市，父母是大学教授")
        iq += 2
elif 4 <= home <= 6:
    if point == 1:
        print("你出生在三线城市，父母是医生")
        strong += 2
    elif point == 2:
        print("你出生在镇上，父母是老师")
        iq += 1
    else:
        print("你出生在镇上，父母是个体户")
        home += 1
else:
    if point == 1:
        print("你出生在农村，父母是辛苦劳作的农民")
        strong += 1
        face -= 2
    elif point == 2:
        print("你出生在穷乡僻壤，父母是无业游民")
        home -= 1
    else:
        print("你出生在镇上，父母感情不和")
        strong -= 1
print(f"颜值:{face},体质:{strong},智力:{iq},家境:{home}")

# 幼年阶段
for age in range(1,11):
    info = f"你今年{age}岁. "
    point = random.randint(1,3)
    if gender == 'girl' and home <= 3 and point == 1:
        info += "你家里人重男轻女思想非常严重，你被遗弃了！"
        print(info)
        print("游戏结束！")
        sys.exit(1)
    elif strong < 6 and point < 3:
        info += "你生了一场病，"
        if home >= 5:
            info += "在父母的悉心照顾下，你康复了"
            strong += 1
            home -= 1
        else:
            info += "你的父母没有精力管你，你的身体状况更糟糕了"
            strong -= 1
    elif face <= 4 and age >= 7:
        info += "你长的太丑了，别的小朋友不喜欢你，"
        if iq > 5:
            info += "你决定用学习填充自己"
            iq += 1
        else:
            if gender == 'boy':
                info += "你和别的小朋友经常打架！"
                strong += 1
                iq -= 1
            else:
                info += "你经常被别的小朋友欺负"
                strong -= 1
    elif iq < 5:
        info += "你看起来傻傻的，"
        if home >= 8 and age >= 6:
            info += "你的父母把你送到更好的学校学习"
            iq += 1
        elif 4 <= home <= 7:
            if gender == 'boy':
                info += "你的父母鼓励你多运动，争取成为运动员"
                strong += 1
            else:
                info += "你的父母鼓励你多打扮自己"
                face += 1
        else:
            info += "你的父母为此经常吵架"
            if point == 1:
                strong -= 1
            elif point == 2:
                iq -= 1
            else:
                pass
    else:
        info += "你健康成长. "
        if point == 1:
            info += "你看起来更结实了"
            strong += 1
        elif point == 2:
            info += "你看起来更好看了"
            face += 1
        else:
            # 无事发生
            pass
    print(info)
    print(f"颜值:{face},体质:{strong},智力:{iq},家境:{home}")
    print("----------------------------------------------")
    time.sleep(1)